<?php

/**
 * Bus form base class.
 *
 * @method Bus getObject() Returns the current form's model object
 *
 * @package    SistemaRutasEc
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseBusForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_bu'   => new sfWidgetFormInputHidden(),
      'id_co'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('cooperativa'), 'add_empty' => false)),
      'disco'   => new sfWidgetFormInputText(),
      'placas'  => new sfWidgetFormInputText(),
      'fechain' => new sfWidgetFormDate(),
    ));

    $this->setValidators(array(
      'id_bu'   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_bu')), 'empty_value' => $this->getObject()->get('id_bu'), 'required' => false)),
      'id_co'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('cooperativa'))),
      'disco'   => new sfValidatorString(array('max_length' => 255)),
      'placas'  => new sfValidatorString(array('max_length' => 255)),
      'fechain' => new sfValidatorDate(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Bus', 'column' => array('placas')))
    );

    $this->widgetSchema->setNameFormat('bus[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Bus';
  }

}
